import request from '../utils/request'

export const addHouseRes = async (data: HouseRes) =>
	await request(`/house-res/add`, 'POST', data)

export const searchGeo = async (longitude: string, latitude: string, radius: string) =>
	await request(`/house-res/geoSearch?longitude=${longitude}&latitude=${latitude}&radius=${radius}`, 'GET')

export const getHouseResFilterPage = async (page: number, house_peace: string, house_use: string, min_rent: string, max_rent: string, house_type: string) =>
	await request(`/house-res/filter?page=${page}&house_peace=${house_peace}&house_use=${house_use}&min_rent=${min_rent}&max_rent=${max_rent}&house_type=${house_type}`, 'GET')

export const getHouseResSearchPage = async (page: number, house_plot: string) =>
	await request(`/house-res/search?page=${page}&house_plot=${house_plot}`, 'GET')

export const getHouseResDetail = async (id: string) =>
	await request(`/house-res/detail/${id}`, 'GET')

export const getHouseResLandLoadPage = async (page: number, landload_id: string) =>
	await request(`/house-res/admin?page=${page}&landload_id=${landload_id}`, 'GET')

export const getHouseResModePage = async (page: number, house_mode: string) =>
	await request(`/house-res/mode?page=${page}&house_mode=${house_mode}`, 'GET')

export const changeStatus = async (id: string, data: { house_status: boolean }) =>
	await request(`/house-res/status/${id}`, 'PATCH', data)

export const delHouseRes = async (id: string, house_plot: string) =>
	await request(`/house-res/del/${id}/${house_plot}`, 'DELETE')

export const uplateHouseRes = async (id: string, data: HouseRes) =>
	await request(`/house-res/edit/${id}`, 'PATCH', data)